//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    imgUrls: [
      '/images/header-image.png',
      '/images/header-image.png',
      '/images/header-image.png',
      '/images/header-image.png'
    ],
    indicatorDots: false,
    autoplay: false,
    interval: 3000,
    duration: 800,
    menu: {
      icons: [
        "/images/header-1.png",
        "/images/header-2.png",
        "/images/header-3.png",
        "/images/header-4.png",
        "/images/header-5.png",
        "/images/header-6.png",
        "/images/header-7.png",
        "/images/header-8.png",
        "/images/header-9.png",
        "/images/header-10.png"
      ],
      texts: [
        "热销楼盘","名车","装修","驾驶集结号","购物",
        "数码", "美美", "超市", "快递", "更多分类",
      ]
    },
    list: [
      { image: "/images/ad-image.png", name: "万科置业", detail: "楼盘户型3室2厅1卫 3室2厅2卫  4室2厅", address:"虹湾大道88号"},
      { image: "/images/ad-image.png", name: "万科置业", detail: "楼盘户型3室2厅1卫 3室2厅2卫  4室2厅", address: "虹湾大道88号" },
      { image: "/images/ad-image.png", name: "万科置业", detail: "楼盘户型3室2厅1卫 3室2厅2卫  4室2厅", address: "虹湾大道88号" },
      { image: "/images/ad-image.png", name: "万科置业", detail: "楼盘户型3室2厅1卫 3室2厅2卫  4室2厅", address: "虹湾大道88号" },
      { image: "/images/ad-image.png", name: "万科置业", detail: "楼盘户型3室2厅1卫 3室2厅2卫  4室2厅", address: "虹湾大道88号" },
      { image: "/images/ad-image.png", name: "万科置业", detail: "楼盘户型3室2厅1卫 3室2厅2卫  4室2厅", address: "虹湾大道88号" },
      { image: "/images/ad-image.png", name: "万科置业", detail: "楼盘户型3室2厅1卫 3室2厅2卫  4室2厅", address: "虹湾大道88号" }
    ]
  },
  //事件处理函数
  bindViewTap: function() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  onLoad: function () {
    if (app.globalData.userInfo) {
      this.setData({
        userInfo: app.globalData.userInfo,
        hasUserInfo: true
      })
    } else if (this.data.canIUse){
      // 由于 getUserInfo 是网络请求，可能会在 Page.onLoad 之后才返回
      // 所以此处加入 callback 以防止这种情况
      app.userInfoReadyCallback = res => {
        this.setData({
          userInfo: res.userInfo,
          hasUserInfo: true
        })
      }
    } else {
      // 在没有 open-type=getUserInfo 版本的兼容处理
      wx.getUserInfo({
        success: res => {
          app.globalData.userInfo = res.userInfo
          this.setData({
            userInfo: res.userInfo,
            hasUserInfo: true
          })
        }
      })
    }
  },
  getUserInfo: function(e) {
    console.log(e)
    app.globalData.userInfo = e.detail.userInfo
    this.setData({
      userInfo: e.detail.userInfo,
      hasUserInfo: true
    })
  }
})
